class InsertionSort():
    def __init__(self) -> None:
        self.count = 0
        pass

    def sort(self,ls):
        N = len(ls)
        for i in range(1,N):
            # 将第i个元素插入到合适的位置
            for j in range(i,0,-1):
                self.count+=1
                if ls[j]<ls[j-1]:
                    ls[j],ls[j-1] = ls[j-1],ls[j]
                else:
                    break
    # 判断是否有序
    def isSorted(self,ls):
        for i in range(1,len(ls)):
            if ls[i]<ls[i-1]:
                return False
        return True

    

        

